<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <script type="text/javascript" src="../internal.js"></script>
</head>
<body>
<div style="padding:10px;">
<div>
<select id="form-type"  onchange="changeType(this)">
<option value="1" selected="selected"  >单选按钮</option>
<option value="2">多选按钮</option>
<option value="3">单行文件</option>
</select>
</div>

<div id="type-1">
数量：<input id="type-1-amount" type="text" value="4" style="width:50px" >
</div>
<div id="type-2"  style="display:none;">
数量：<input id="type-2-amount" type="text" value="4" style="width:50px" >
</div>
<div id="type-3"  style="display:none;" >
宽度：<input id="type-3-width" type="text" value="80" style="width:50px" >px
</div>

</div>

<script type="text/javascript">

var currType  = 1 ;

var letters = ['' , 'A' ,'B','C','D','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W' ,'X' ,'Y','Z']  ;

function changeType(select){
	
	var selectedIndex  = select.selectedIndex ;
	
	var typeValue  =  select.options[selectedIndex].value ;
	
	
	document.getElementById("type-"+currType).style.display="none" ;
	
	
	document.getElementById("type-"+typeValue).style.display="" ;
	
	
	currType =  typeValue ;
	
	
	
	
}

function isNum(v){
	return /^\d+$/.test(v);
}
    
    window.onload = function () {
        
        //点击OK按钮
        dialog.onok = function(){
        	
        	var sid = new Date().getTime() ;
        	
        	 var str='<p  class="_group_  g'+sid+'"   >';
        	 
        	if(currType == 1 ){
        		
        		var amount  = document.getElementById("type-1-amount").value ;
        		
        		if( !isNum(amount) && parseInt( amount ) >=1 && parseInt ( amount ) <= 26){
        			alert("请输入数字,且为1到时26");
        			return false ;
        		}
        		
        		var timestamp  = new Date().getTime();
        		
        		for(var i =1 ; i <= amount ; i++ ){
        			str += '<label><input type="radio"  name="answerValue_'+timestamp+'"  value="'+letters[i]+'" />'+letters[i]+'</label> ' ;
        		}
        		
        	}else if( currType == 2 ){
        		
				var amount  = document.getElementById("type-2-amount").value ;
        		
        		if( !isNum(amount) && parseInt( amount ) >=1 && parseInt ( amount ) <= 26){
        			alert("请输入数字,且为1到时26");
        			return false ;
        		}
        		
        		var timestamp  = new Date().getTime();
        		
        		for(var i =1 ; i <= amount ; i++ ){
        			str += '<label><input type="checkbox"  name="answerValue_'+timestamp+'"  value="'+letters[i]+'" />'+letters[i]+'</label>' ;
        		}
        		
        	}else if( currType == 3 ){
        		var width =  document.getElementById("type-3-width").value ;
        		
        		if( !isNum(width) && parseInt( width ) >=1 ){
        			alert("请输入数字,且大于0");
        			return false ;
        		}
        		
        		str += '<input type="text"  name="answerValue_'+(new Date().getTime())+'"  style="width:'+width+'px;"  />' ;
        	}
        	str +='</p>' ;
        	
            editor.execCommand("insertHTML",str);
            
        };
        
       
    };
</script>

</body>
</html>
